<html>
<head><meta charset="utf-8"><title>lint docs · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lint.20docs.html">lint docs</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="221319921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lint%20docs/near/221319921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lint.20docs.html#221319921">(Dec 31 2020 at 22:03)</a>:</h4>
<p>Hi, I have defined a lint here: <a href="https://github.com/sexxi-goose/rust/pull/42/commits/a29dde10b5bfdd6c1f29095a6b5f824c8cb79106">https://github.com/sexxi-goose/rust/pull/42/commits/a29dde10b5bfdd6c1f29095a6b5f824c8cb79106</a></p>
<p>But the doc tests for it are failing when I run the tests locally:</p>
<div class="codehilite"><pre><span></span><code>error: failed to test example in lint docs for `disjoint_capture_drop_reorder` in /users/a52arora/rust/compiler/rustc_lint_defs/src/builtin.rs:2907: did not find lint `disjoint_capture_drop_reorder` in output of example, got:
</code></pre></div>
<p>The lint is set to be <code>[allow]</code> by default because this is just the first step and it isn't quite there yet.</p>
<p>When I test this with <code>deny(disjoint_capture_drop_reorder)</code> it does work, so I'm not sure if it needs to deny/warn by default to pass the test or if I'm misisng something?</p>



<a name="221320074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lint%20docs/near/221320074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lint.20docs.html#221320074">(Dec 31 2020 at 22:05)</a>:</h4>
<p>Also is there a way to get around not having to use <code>_y</code> as the name of the field, without triggering an unused code warning? <code>[allow(unused)]</code> didn't help</p>



<a name="221320894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lint%20docs/near/221320894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lint.20docs.html#221320894">(Dec 31 2020 at 22:15)</a>:</h4>
<p>And is there a way to run these tests without having to compile everything again? These run at the very end of stage1 testsuite <span aria-label="frown" class="emoji emoji-1f641" role="img" title="frown">:frown:</span></p>



<a name="221320962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lint%20docs/near/221320962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lint.20docs.html#221320962">(Dec 31 2020 at 22:16)</a>:</h4>
<p>I would expect <code>x.py test --stage 1 compiler/rustc_lint_defs</code> to work</p>



<a name="221320972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lint%20docs/near/221320972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lint.20docs.html#221320972">(Dec 31 2020 at 22:16)</a>:</h4>
<p>the rest I'm not sure off the top of my head, I'll look when I get off work</p>



<a name="221320995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lint%20docs/near/221320995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lint.20docs.html#221320995">(Dec 31 2020 at 22:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/lint.20docs/near/221320962">said</a>:</p>
<blockquote>
<p>I would expect <code>x.py test --stage 1 compiler/rustc_lint_defs</code> to work</p>
</blockquote>
<p>I'll try that</p>



<a name="221321079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lint%20docs/near/221321079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lint.20docs.html#221321079">(Dec 31 2020 at 22:18)</a>:</h4>
<p>if that doesn't work, try looking around <code>src/bootstrap/*.rs</code> and see if you find something</p>



<a name="221321395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lint%20docs/near/221321395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lint.20docs.html#221321395">(Dec 31 2020 at 22:23)</a>:</h4>
<p>Sounds good</p>



<a name="221323723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lint%20docs/near/221323723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lint.20docs.html#221323723">(Dec 31 2020 at 23:11)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> If you have an allow-by-default lint, then the example needs to include <code>#![deny(disjoint_capture_drop_reorder)]</code> at the top in order to trigger it for the documentation.</p>
<p>Also, the error should have come with some instructions on how to run the tests, did that not show up?</p>
<div class="codehilite"><pre><span></span><code>This error was generated by the lint-docs tool.
This tool extracts documentation for lints from the source code and places
them in the rustc book. See the declare_lint! documentation
https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint_defs/macro.declare_lint.html
for an example of the format of documentation this tool expects.

To re-run these tests, run: ./x.py test --keep-stage=0 src/tools/lint-docs
The --keep-stage flag should be used if you have already built the compiler
and are only modifying the doc comments to avoid rebuilding the compiler.
</code></pre></div>
<p>I think re-running the test should take less than a minute.</p>
<p>You should be able to use <code>#![allow(unused)]</code> at the top.  I recommend prefixing it with a # to hide it, like this: <a href="https://github.com/rust-lang/rust/blob/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_lint/src/builtin.rs#L2311">https://github.com/rust-lang/rust/blob/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_lint/src/builtin.rs#L2311</a></p>



<a name="221323775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lint%20docs/near/221323775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lint.20docs.html#221323775">(Dec 31 2020 at 23:12)</a>:</h4>
<p>Thanks <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="221353590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lint%20docs/near/221353590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lint.20docs.html#221353590">(Jan 01 2021 at 14:19)</a>:</h4>
<p>This worked like a charm, thank you:)</p>



<a name="221429485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lint%20docs/near/221429485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lint.20docs.html#221429485">(Jan 03 2021 at 02:33)</a>:</h4>
<p>Not sure if this is expected but  <code>./x.py test --keep-stage=0 src/tools/lint-docs</code> didn't fail because an error was being emitted because of the lint, which does happen when the ustdoc test runs.</p>
<p>Eg: <a href="https://github.com/rust-lang/rust/pull/80629#issuecomment-753529406">https://github.com/rust-lang/rust/pull/80629#issuecomment-753529406</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>